home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ======================================================================== */ /* = Programmname : SimpleOP V9.10 = */ /* = = */ /* ======================================================================== */ /* = Author/Copyright : (c) 1993-94 by Andreas Ralph Kleinert. = */ /* = Freeware. All rights reserved. = */ /* = = */ /* = Use it as an example for programming = */ /* = superview.library ! = */ /* = = */ /* ======================================================================== */ /* = Last Update : 10.12.10994 = */ /* = = */ /* ======================================================================== */ /* = Remarks : Needs "asl.library" V37+ = */ /* = and "superview.library" V9+. = */ /* ======================================================================== */ /* = Compiler : SAS/C V6.51 = */ /* = (smakefile) = */ /* ======================================================================== */ #include <exec/types.h> #include <exec/memory.h> #include <intuition/intuitionbase.h> /* accessing IntuitionBase->FirstScreen */ #include <superview/superview.h> #include <superview/superviewbase.h> #include <libraries/asl.h> #include <workbench/startup.h> #include <proto/exec.h> #include <proto/dos.h> #include <proto/asl.h> #include <proto/superview.h> #include <proto/superviewsupport.h> #include <stdio.h> #include <stdlib.h> #include <string.h> /* Help- and Info- Texts */ char entry1_text [] = "\2331;32;40mSimpleOP V9.10 \2330;32;40m\2333;32;40m(FREEWARE)\2330;32;40m\n(c) 1993-94 by Andreas Ralph Kleinert.\nAndreas R. Kleinert, Grube Hohe Grethe 23, D-57074 Siegen, Germany.\n"; char entry2_text [] = "Demonstrates SVOperator usage.\n"; char entry3_text [] = "USAGE : \2330;33;40mSimpleOP\2330;31;40m <PicFileName>\n"; char ver_text [] = "\0$VER: SimpleOP V9.10 (10.12.94)"; /* *************************************************** */ /* * * */ /* * Error-Messages for Leave() and KF_Message() * */ /* * * */ /* *************************************************** */ char asllib_text [] = "You need \42asl.library\42 V37+ !"; char svlib_text [] = "You need \42superview.library\42 V9+ !"; char svsuplib_text [] = "You need \42superviewsupport.library\42 V4+ !"; /* *************************************************** */ /* * * */ /* * Function Declarations * */ /* * * */ /* *************************************************** */ void __regargs SimpleOP(char *filename); void __regargs Leave(char *endtext, long code); /* Functions from module "SimpleOP_Subs.o" : */ extern void __stdargs K_Printf(char *formatstring, ...); /* *************************************************** */ /* * * */ /* * Additional Base Declarations * */ /* * * */ /* *************************************************** */ extern struct ExecBase *SysBase; struct Library *AslBase = N; struct SuperViewBase *SuperViewBase = N; struct SVSupportBase *SVSupportBase = N; struct IntuitionBase *IntuitionBase = N; /* Copied from SuperViewBase. */ /* Do not close. Only used for */ /* accessing FrontScreen */ /* *************************************************** */ /* * * */ /* * MAIN * */ /* * * */ /* *************************************************** */ extern struct WBStartup *WBenchMsg; char *wbloadname = N; long wb = FALSE; void main(long argc, char **argv) { if(!argc) { wb = TRUE; if(WBenchMsg->sm_NumArgs>1) wbloadname = WBenchMsg->sm_ArgList[1].wa_Name; } if( argc > 3 || (argv[1][0] =='?')||(argv[2][0] =='?')) { K_Printf("%s%s%s", entry1_text, entry2_text, entry3_text); Leave(N, 0); } AslBase = (struct Library *) OpenLibrary("asl.library", 37); if(!AslBase) Leave(asllib_text, 102); SuperViewBase = (struct SuperViewBase *) OpenLibrary("superview.library", 9); if(!SuperViewBase) Leave(svlib_text, 103); SVSupportBase = (struct SVSupportBase *) OpenLibrary("superviewsupport.library", 4); if(!SVSupportBase) Leave(svsuplib_text, 104); IntuitionBase = SuperViewBase->svb_IntuitionBase; /* ^ if NULL, sv-lib wouldn't have opened ! */ /* Show */ if(argc < 2 && !wbloadname) { struct FileRequester *request; struct TagItem __aligned tags[4]; char namebuffer [256]; namebuffer[0] = (char) 0; tags[0].ti_Tag = (Tag) ASL_Hail; tags[0].ti_Data = (ULONG) "Select Picture to operate with XOR:"; tags[1].ti_Tag = (Tag) ASL_OKText; tags[1].ti_Data = (ULONG) " Display "; tags[2].ti_Tag = (Tag) ASL_CancelText; tags[2].ti_Data = (ULONG) " Quit "; tags[3].ti_Tag = (Tag) TAG_DONE; tags[3].ti_Data = (ULONG) N; request = AllocAslRequest(ASL_FileRequest, N); if(request) { if(AslRequest(request, &tags[0])) { strcpy(namebuffer, request->rf_Dir); if( (namebuffer[strlen(namebuffer)-1] != ':') && (namebuffer[strlen(namebuffer)-1] != '/') && (namebuffer[0] != (char) 0) ) strcat(namebuffer, "/"); strcat(namebuffer, request->rf_File); if(namebuffer[0] != (char) 0) SimpleOP(namebuffer); } FreeAslRequest(request); } }else { if(wbloadname) SimpleOP(wbloadname); else SimpleOP(argv[1]); } Leave(N, 0); } /* *************************************************** */ /* * * */ /* * Operator-Function ( + Show) * */ /* * * */ /* *************************************************** */ void __regargs SimpleOP(char *filename) { ULONG retval = SVERR_NO_ERROR; APTR handle = N; struct SVSUP_DisplayHandle *displayhandle = N; APTR dummy; displayhandle = AllocVec(sizeof(struct SVSUP_DisplayHandle), MEMF_CLEAR|MEMF_PUBLIC); if(displayhandle) { SVL_GetGlobalDriver(&displayhandle->SVDriverNode, N); handle = SVL_AllocHandle(N); if(handle) { if(!(retval = SVL_InitHandleAsDOS(handle, N))) { displayhandle->WinIDCMP = IDCMP_MOUSEBUTTONS; displayhandle->ScrType = CUSTOMSCREEN; retval = SVL_ReadToGfxBuffer(handle, filename); if(!retval) retval = SVL_GetGfxBuffer( handle, (APTR) &dummy, N); { APTR handle2; handle2 = SVL_AllocHandle(N); if(handle2) { retval = SVL_DoOperation(handle2, (APTR) dummy, (APTR) &displayhandle->SVGfxBuffer, (APTR) FindName(&SuperViewBase->svb_SVOperatorList, "XOR.svoperator"), N); if(!displayhandle->SVGfxBuffer) K_Printf("\nERROR: GfxBuffer missing...\n"); if(!retval && displayhandle->SVGfxBuffer) { retval = SVSUP_DisplayGfxBuffer(displayhandle); if(!retval) { if(displayhandle->Window) { WaitPort(displayhandle->Window->UserPort); } } SVSUP_UnDisplayGfxBuffer(displayhandle); } SVL_FreeHandle(handle2); }else retval = SVERR_NO_HANDLE; } } SVL_FreeHandle(handle); }else retval = SVERR_NO_HANDLE; FreeVec(displayhandle); }else retval = SVERR_NO_MEMORY; if(retval) K_Printf("\n%s\n", SVL_GetErrorString(retval)); } /* *************************************************** */ /* * * */ /* * LEAVE : Global Exit Function Replacement * */ /* * * */ /* *************************************************** */ void __regargs Leave(char *endtext, long code) { if(SVSupportBase) CloseLibrary((APTR) SVSupportBase); if(SuperViewBase) CloseLibrary((APTR) SuperViewBase); if(AslBase) CloseLibrary((APTR) AslBase); if(endtext) if(!wb) K_Printf("%s\n", endtext); exit(code); }